from cmath import *
from math import *
from decimal import *
from collections import *
import numbers
from operator import index
import sys
def _input(): return map(int, input().split())
def _list(): return list(map(int, input().split()))
def _int(): return int(input())
def solves():
n,k=_input()
s=input()
mn=inf
char=''
alpha=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for i in range (k):
if alpha[i] not in s:
print(0)
return
if (s.count(alpha[i])<=mn):
mn=min(mn,s.count(alpha[i]))
print(mn*k)
t=1
for _ in range(0,t):
solves()
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define dbg printf("in\n")
#define nl printf("\n");
#define N 105
#define inf 10000000000000000
#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%I64d", &n)
#define sffl(n,m) scanf("%I64d%I64d",&n,&m)
#define pf(n) printf("%d ",n)
#define pff(n,m) printf("%d %d\n",n,m)
#define pffl(n,m) printf("%I64d %I64d\n",n,m)
#define pfl(n) printf("%I64d\n",n)
#define pfs(s) printf("%s",s)
#define pb push_back
#define pp pair<int,int>
using namespace std;
int main()
{
//freopen("in.txt","r",stdin);
int i,j,k;
int n,m;
string s;
int a[26];
memset(a,0,sizeof(a));
sff(n,k);
cin>>s;
for(i=0;i<n;i++)
{
a[s[i]-'A']++;
}
int mn=n;
for(i=0;i<k;i++)
mn=min(mn,a[i]);
pf(mn*k);
return 0;
}
892A - Greed | 32A - Reconnaissance |
1236D - Alice and the Doll | 1207B - Square Filling |
1676D - X-Sum | 1679A - AvtoBus |
1549A - Gregor and Cryptography | 918C - The Monster |
4B - Before an Exam | 545B - Equidistant String |
1244C - The Football Season | 1696B - NIT Destroys the Universe |
1674A - Number Transformation | 1244E - Minimizing Difference |
1688A - Cirno's Perfect Bitmasks Classroom | 219A - k-String |
952A - Quirky Quantifiers | 451B - Sort the Array |
1505H - L BREAK into program | 171E - MYSTERIOUS LANGUAGE |
630D - Hexagons | 1690D - Black and White Stripe |
1688D - The Enchanted Forest | 1674C - Infinite Replacement |
712A - Memory and Crow | 1676C - Most Similar Words |
1681A - Game with Cards | 151C - Win or Freeze |
1585A - Life of a Flower | 1662A - Organizing SWERC |